﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class View_TEST_Default2 : System.Web.UI.Page
{
    delegate int del(int a,int b);

    delegate void TestDelegate(string s);

    protected void Page_Load(object sender, EventArgs e)
    {
        string serviceDll = Utility.GetWebConfigAppSettingsValue("serviceDll");
        string bin = Utility.GetWebConfigAppSettingsValue("binParh");
        string path = string.Format(@"{0}{1}", Server.MapPath("~"),bin);
        string dll = string.Format(@"{0}{1}",path,serviceDll);
        System.Reflection.Assembly xx = System.Reflection.Assembly.LoadFrom(dll);
        //System.Reflection.MethodInfo mi = xx.GetTypes()[0].GetMethod("GetSummaryData");
        Type t = xx.GetType("MISAPP.Classify.Service.Service_WMG001");
        object o = System.Activator.CreateInstance(t);
        System.Reflection.MethodInfo mi = t.GetMethod("GetCriteriaArray"); //xx.GetTypes()[0].GetMethod("GetSummaryData");
        string[] aa =(string[]) mi.Invoke(o, null);
        
        //string[] aa = mi.Invoke

        if (!IsPostBack)
        {
            GetData();
        }

        //int x1, y1;
        //x1 = 13;
        //y1 = 10;

        //del myDelegate = (int x, int y) =>{return x % y > 0 ? x / y + 1 : x / y ;};
        //int j = myDelegate(x1,y1); //j = 25

        //double xxx = x1 /(double)y1;

        

        //Response.Write(j);
        //Response.Write("<br>");
        //Response.Write(xxx);
        

    }

    protected void GetData()
    {
        System.Data.DataTable dtReport = new System.Data.DataTable();
        dtReport.Columns.Add("FLD1", typeof(System.String));
        dtReport.Columns.Add("FLD2", typeof(System.Double));
        dtReport.Columns.Add("FLD3", typeof(System.DateTime));
        System.Data.DataRow row = dtReport.NewRow();

        row[0] = "123";
        row[1] = 1234567;
        row[2] = DateTime.Now;

        dtReport.Rows.Add(row);

        row = dtReport.NewRow();

        row[0] = "456";
        row[1] = 1234567;
        row[2] = DateTime.Now;

        dtReport.Rows.Add(row);

        string[] strList =  {"FLD1"};

        //complexGrid11.SetData(dtReport, strList);
        GV1.DataSource = dtReport;
        GV1.DataBind();
        foreach (DataControlFieldCell cll in GV1.HeaderRow.Cells)
        {
            Response.Write(string.Format("Cells:{0}<br>", cll.Text));
        }

       
        
    }

    protected void GV1_OnPageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GV1.PageIndex = e.NewPageIndex;
        GetData();
        Response.Write("GV1_OnPageIndexChanging<br>");
    }

    protected void GV1_OnRowCommand(object sender, GridViewCommandEventArgs e)
    {
        Response.Write("GV1_OnRowCommand<br>");
    }

    protected void GV1_OnSorting(object sender, GridViewSortEventArgs e)
    {
        Response.Write(e.SortDirection.ToString());
    }
    protected void GV1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        Response.Write(string.Format( "GV1_RowCreated:{0}<br>",e.Row.RowType) );
        if (e.Row.RowType == DataControlRowType.Header)
        { }
    }
    protected void GV1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        { }
        Response.Write(string.Format("GV1_RowDataBound:{0}<br>", e.Row.RowType));
    }
    protected void GV1_DataBound(object sender, EventArgs e)
    {
        Response.Write(string.Format("GV1_DataBound:{0}<br>",""));
        GV1.HeaderRow.Cells[0].Text = "A222";
    }
}
